package com.ywb.controller;


import com.ywb.pojo.Result;
import lombok.RequiredArgsConstructor;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequiredArgsConstructor
@RestController
@RequestMapping("/ai")
public class ChatController {
    private final ChatClient chatClient;
    @RequestMapping(value = "/chat", produces = "text/html;charset=utf-8")
    public String chat(String prompt)
    {
        return chatClient.prompt().user(prompt).call().content();
    }

    @GetMapping("/chat2")
    public Result chat2(String prompt)
    {
        return Result.success(chatClient.prompt().user(prompt).call().content());
    }


}
